--help should always go to stdout
authorOwen W. Taylor <otaylor@fishsoup.net>
Thu, 25 Sep 2014 06:34:30 +0000 (02:34 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Thu, 25 Sep 2014 18:28:58 +0000 (14:28 -0400)
The standard convention is that the  output of --help should go to standard
output (so that it can be piped to a pager and searched.) See, e.g., the
GNU coding standards.

https://bugzilla.gnome.org/show_bug.cgi?id=737194

src/ostree/ot-admin-builtin-instutil.c
src/ostree/ot-builtin-admin.c
src/ostree/ot-main.c

index c87ffa4ea01d761747c4d18cb7ae4acb9b5270e4..a0a29d286ce7509663be1466d8c559a42bf4f2e4 100644 (file)
@@ -119,12 +119,14 @@ ot_admin_builtin_instutil (int argc, char **argv, OstreeSysroot *sysroot, GCance
 
   if (subcommand_name == NULL)
     {
+      void (*print_func) (const gchar *format, ...) = want_help ? g_print : g_printerr;
+
       subcommand = admin_instutil_subcommands;
-      g_print ("usage: ostree admin instutil COMMAND [options]\n");
-      g_print ("Builtin commands:\n");
+      print_func ("usage: ostree admin instutil COMMAND [options]\n");
+      print_func ("Builtin commands:\n");
       while (subcommand->name)
         {
-          g_print ("  %s\n", subcommand->name);
+          print_func ("  %s\n", subcommand->name);
           subcommand++;
         }
 
index ef54797e68f720330289a2a3aa9ea1396fc810b3..afc3bb33a0c74262853229e74e5dd3c8741f7ddb 100644 (file)
@@ -147,12 +147,14 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
 
   if (subcommand_name == NULL)
     {
+      void (*print_func) (const gchar *format, ...) = want_help ? g_print : g_printerr;
+
       subcommand = admin_subcommands;
-      g_print ("usage: ostree admin --sysroot=PATH COMMAND [options]\n");
-      g_print ("Builtin commands:\n");
+      print_func ("usage: ostree admin --sysroot=PATH COMMAND [options]\n");
+      print_func ("Builtin commands:\n");
       while (subcommand->name)
         {
-          g_print ("  %s\n", subcommand->name);
+          print_func ("  %s\n", subcommand->name);
           subcommand++;
         }
 
index 6adb2d22f1427bd23222b65d7c2ada7154dd0695..585e44f7f6cc7affb603d88a83d8067872aa1459 100644 (file)
@@ -201,7 +201,7 @@ ostree_run (int    argc,
           g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
                                "No command specified");
         }
-      ostree_usage (argv, commands, TRUE);
+      ostree_usage (argv, commands, !want_help);
       goto out;
     }